package com.sq.partner.manager.dao.impl;

import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Repository;

import com.sq.partner.manager.dao.DictManagerDao;
import com.sq.partner.manager.mybatis.model.DictDto;
import com.sq.partner.manager.util.LogUtil;
import com.sq.partner.manager.util.Page;

@Repository
public class DictManagerDaoImpl extends BaseDaoImpl implements DictManagerDao {
	
	private static Logger logger = LogUtil.getLog(DictManagerDaoImpl.class);

	@Override
	public Page<DictDto> queryDictDtoPageByCriteria(Page<DictDto> page)
			throws Exception {
		Map<String, Object> map=page.getMap();
		Long count=(Long) this.query("queryDictCount", map);
		logger.debug("查询结果总条数 ： " + count);
		page.setTotal(count);
		@SuppressWarnings("unchecked")
		List<DictDto> dicts=this.queryList("queryDictList", map);
		page.setData(dicts);
		return page;
	}

	@Override
	public void updateGatewayDict(DictDto dict) throws Exception {
		this.update("updateGatewayDictNotNull", dict);
	}

	@Override
	public void insertGatewayDict(DictDto dict) throws Exception {
		this.add("insertGatewayDictNotNull", dict);		
	}

	@Override
	public void deleteGatewayDict(DictDto dict) throws Exception {
		this.delete("deleteGatewayDict", dict);
		
	}

	@Override
	public DictDto queryDictDtoPageByInstance(DictDto dict) throws Exception{
		logger.debug("---进入查重SQL执行逻辑--- : " + dict.getCode() + dict.getCodeType() );
		return (DictDto) this.query("queryDictDtoPageByInstance", dict);
		
	}
	
	@Override
	public Page<DictDto> querySchoolConfigList(Page<DictDto> page)
			throws Exception {
		Map<String, Object> map=page.getMap();
		Long count=(Long) this.query("querySchoolConfigCount", map);
		logger.debug("查询结果总条数 ： " + count);
		page.setTotal(count);
		@SuppressWarnings("unchecked")
		List<DictDto> dicts=this.queryList("querySchoolConfigList", map);
		page.setData(dicts);
		return page;
	}

	@Override
	public void deleteGatewayDictByDeptNo(String deptNo) throws Exception {
		
		this.delete("deleteGatewayDictByDeptNo", deptNo);
		
	}
}
